#pragma once

#include <maya/MPxCommand.h>
#include <maya/MDagPathArray.h>
#include <maya/MDagPath.h>
#include <maya/MDGModifier.h>


class MSyntax;

class xsCustomSkinCmd:public MPxCommand
{
public:
	xsCustomSkinCmd();
	virtual ~xsCustomSkinCmd();

	virtual MStatus doIt( const MArgList& args ) override;
	virtual MStatus undoIt() override;
	virtual MStatus redoIt() override;
	virtual bool isUndoable() const override;

	static void* creator();
	static MSyntax createSyntax();
private:
	MStatus AddDeformerAndConnect();
	void StorePreBindMatrix(MFnDependencyNode& deformerNode, MPlug& worldMatrix, unsigned int index);
	void CalculateWeights(MFnDependencyNode& deformerNode);
public:
	static MString cmdName;

	// joints to skin
	MDagPathArray dagpathJoints;
	// skined mesh's transform
	MDagPath dagpathMesh;
	MDGModifier dgModifier;
};
